/*
 * Author: Alberto De Pena
 * Applied Algorithms
 * subvector.cpp
*/

#include <iostream>
#include <fstream>
using namespace std;

void main()
{
    ifstream fin;
    ofstream fout;
    long long m, n, a, b, vector, maximum, number;

    fin.open( "subvector.in" );
    fout.open( "subvector.out" );

    fin >> m;

    for( a = 0; a < m; a++ )
    {
        fin >> n;
        maximum = 0;
        vector = 0;
        for( b = 0; b < n; b++ )
        {
            fin >> number;
            vector =  vector + number;
            if( vector > maximum )
                maximum = vector;
            if( vector <= 0 )
                vector = 0;
        }
        fout << maximum << endl;
    }

    fin.close();
    fout.close();
}

